import { ref } from "vue";
import { generateId } from '../utils/todoStorage'
export default function useNewTodo(todoRef) {
    const newTodoRef = ref(""); // 新任务标题
    const addTodo = () => { // 新增一个任务
        const value = newTodoRef.value
        if (!value) {
            return
        }
        todoRef.value.unshift({ id: generateId(), title: value.trim(), completed: false })
        newTodoRef.value = ''
    }
    return { newTodoRef, addTodo }
}